package org.yzl.designPatterns.singleton;

/**
 * 单例模式
 */
public class Singleton {
    private static Singleton instance  = null;

    /* 私有构造方法，防止被实例化 */
    private Singleton(){};

    //获取实例方法
    public static Singleton getInstance(){
        if(instance == null){
            initInstance();
        }
        return instance;
    }

    //
    private static synchronized void initInstance(){
        if(instance == null){
            instance = new Singleton();
        }
    }
}
